<?php

// require_once 'Zend/Gdata/Extension.php';
require_once dirname(__FILE__) . '/../../Extension/Params.php';
require_once dirname(__FILE__) . '/TextValues.php';

class Rats_Extension_OverlayParams extends Raws_Extension_Params
{

    // protected $_rootNamespace = 'raws';
    // protected $_rootElement = 'params';
 
    protected $_id = null;
    protected $_filename = null;
    protected $_mode = null;
    protected $_threshold = null;

    public function __construct($id = null, $filename = null, $mode = null, $threshold = null) 
    {
        // foreach (Rats::$namespaces as $nsPrefix => $nsUri) {
        //     $this->registerNamespace($nsPrefix, $nsUri);
        // }
        parent::__construct();
        $this->_id = $id;
        $this->_filename = $filename;
        $this->_mode = $mode;
        $this->_threshold = $threshold;
    }
    
    /**
     * Retrieves a DOMElement which corresponds to this element and all
     * child properties.  This is used to build an entry back into a DOM
     * and eventually XML text for application storage/persistence.
     *
     * @param DOMDocument $doc The DOMDocument used to construct DOMElements
     * @return DOMElement The DOMElement representing this element and all
     *          child properties.
     */
    public function getDOM($doc = null)
    {
        $element = parent::getDOM($doc);
        if ($this->_filename !== null) {
            $element->appendChild($this->_filename->getDOM($element->ownerDocument));
        }
        if ($this->_id !== null) {
            $element->appendChild($this->_id->getDOM($element->ownerDocument));
        }
        if ($this->_mode !== null) {
            $element->appendChild($this->_mode->getDOM($element->ownerDocument));
        }
        if ($this->_threshold !== null) {
            $element->appendChild($this->_threshold->getDOM($element->ownerDocument));
        }
        return $element;
    }

    /**
     * Creates individual Entry objects of the appropriate type and
     * stores them as members of this entry based upon DOM data.
     *
     * @param DOMNode $child The DOMNode to process
     */
    protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        
        switch ($absoluteNodeName) {
            case $this->lookupNamespace('raws') . ':' . 'filename'; 
                $filename = new Rats_Extension_Filename();
                $filename->transferFromDOM($child);
                $this->_filename = $filename;
                break;
            case $this->lookupNamespace('raws') . ':' . 'id'; 
                $id = new Rats_Extension_Id();
                $id->transferFromDOM($child);
                $this->_id = $id;
                break;
            case $this->lookupNamespace('raws') . ':' . 'mode'; 
                $mode = new Rats_Extension_Mode();
                $mode->transferFromDOM($child);
                $this->_mode = $mode;
                break;
            case $this->lookupNamespace('raws') . ':' . 'threshold'; 
                $threshold = new Rats_Extension_Threshold();
                $threshold->transferFromDOM($child);
                $this->_threshold = $threshold;
                break;
            default:
                parent::takeChildFromDOM($child);
                break;
        }
    }

    public function getFilename()
    {
        return $this->_filename;
    }

    public function setFilename($value)
    {
        $this->_filename = $value;
        return $this;
    }

    public function getId()
    {
        return $this->_id;
    }

    public function setId($value)
    {
        $this->_id = $value;
        return $this;
    }

    public function getMode()
    {
        return $this->_mode;
    }

    public function setMode($value)
    {
        $this->_mode = $value;
        return $this;
    }

    public function getThreshold()
    {
        return $this->_threshold;
    }

    public function setThreshold($value)
    {
        $this->_threshold = $value;
        return $this;
    }

}
